Write a function to reduce duplicate code

welcome to shbcf.ru